@extends('home.inc.common')
@section('title')
    <title>{{ $anchor->name }}官方直播间地址_{{ $anchor->name }}微博地址_{{ $anchor->name }}视频_{{ $anchor->name }}最新动态_奇异果聚合-看点有意思的</title>
    <meta name="keywords" content="{{ $anchor->name }}，{{ $anchor->name }}直播间地址，{{ $anchor->name }}视频" />
    <meta name="description" content="{{ $anchor->name }}官方直播间地址.奇异果聚合全网追踪主播动态，帮助收录整理{{ $anchor->name }}微博地址，{{ $anchor->name }}视频，{{ $anchor->name }}最新动态、{{ $anchor->name }}最新视频，在奇异果您可以订阅主播，任何平台主播在线立即微信提醒，马上来试试吧…" />
    <link href="{{ asset('home_new/css/libs.css') }}" rel="stylesheet" type="text/css" />
    <link href="{{ asset('home_new/css/global.css') }}" rel="stylesheet" type="text/css" />
    <link href="{{ asset('home_new/css/qyg2016.css') }}" rel="stylesheet" type="text/css" />
    <link href="{{ asset('home_new/css/page_ub_detail.css') }}" rel="stylesheet" type="text/css" />
    <link href="{{ asset('home_new/css/ub_detail.css') }}" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="{{asset('home/js/jquery-3.1.0.min.js')}}"></script>
    <script type="text/javascript" src="{{asset('pulgin/layer/layer.js')}}"></script>
    <script src="http://static.geetest.com/static/tools/gt.js"></script>
    <link rel="icon" href="/favicon.ico" />
@endsection
@section('content')
    <div class="wrap">
        <div id="main" class="post_wrap">
            @include('home.anchor.common-cates')
            <div class="media_content">
                <div class="content_video v_content">
                    <div class="video_title v_title">
                        <div class="video_ub">
                            <div class="video_ub_pic">
                                <img src="{{ $anchor->avatar }}" alt="">
                            </div>
                            <div class="video_ubtitle">
                                <h2>{{ $anchor->room_name }}</h2>
                                <span class="v_zb">
                                <a href="{{ url('/') }}">
                                    首页
                                </a>
                                &nbsp;&nbsp;>
                                </span>
                                <span class="v_zb">
                                <a href="{{ route('anchor.index') }}">
                                    直播
                                </a>
                                &nbsp;&nbsp;>&nbsp;&nbsp;
                                </span>
                                @if (!empty($anchor->cate))
                                    <span class="v_zb">
                                    <a href="{{ route('anchor.cate', [$anchor->cate->cate_id]) }}">
                                        {{$anchor->cate->cate_name}}
                                    </a>
                                </span>
                                @endif
                                <div class="video_nbfx v_zb-content">
                                    <a href="#"><img src="{{ asset('home_new/images/ub_detail/user.png') }}">{{ $anchor->name }}</a>
                                    <a href="#"><img src="{{ asset('home_new/images/ub_detail/view.png') }}">{{ $anchor->online }}</a>
                                </div>
                            </div>
                            <div class="viseo_ubfx">
                                <span>
                                    <button class="v_csm"><a href="{{ $anchor->url }}">传送门</a></button>
                                    @if (empty($user) || ! $user->isFollowedAnchor($anchor))
                                        <button class="v_gz
                                    @if(empty($user))
                                                login_in
                                            @elseif(!$user->isBindWx())
                                                bind_wx
                                            @endif"
                                                id="follow" onclick="follow()">关注</button>
                                    @else
                                        <button class="v_ygz" id="unfollow" onclick="unfollow()">已关注</button>
                                    @endif
                                </span>
                                <div class="bdsharebuttonbox ub_detail_btn v_detail-btn">
                                    <a href="#" class="bds_more" data-cmd="more"></a>
                                    <a href="#" class="bds_qzone" data-cmd="qzone" title="分享到QQ空间"></a>
                                    <a href="#" class="bds_tsina" data-cmd="tsina" title="分享到新浪微博"></a>
                                    <a href="#" class="bds_tqq" data-cmd="tqq" title="分享到腾讯微博"></a>
                                    <a href="#" class="bds_renren" data-cmd="renren" title="分享到人人网"></a>
                                    <a href="#" class="bds_weixin" data-cmd="weixin" title="分享到微信"></a>
                                </div>
                                <script>
                                    window._bd_share_config = {
                                        common : {
                                            bdText : '{{ $anchor->room_name }}',
                                            bdDesc : '{{ $tag->content }}',
                                            bdUrl : 'http://www.qiyiguo.tv/anchors/{{ $tag->id }}',
                                            bdPic : '{{ $anchor->cover }}'
                                        },
                                        share : [{
                                            "bdSize" : 24
                                        }]
                                    }
                                    with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?cdnversion='+~(-new Date()/36e5)];
                                </script>
                            </div>

                        </div>
                        <div class="ub_weibo_title">主播微博</div>
                        <div class="ub_border">
                            <div class="ub_border_l"></div>
                            <div class="ub_border_r"></div>
                        </div>
                        <div class="ub_weibo">
                            <div class="ub_border_l ub_weibo_l"></div>
                            <div class="ub_border_r ub_weibo_r"></div>
                        </div>
                    </div>
                    <div class="video_post v_post">
                        <div class="post_player clear">
                            @if ($anchor->status == 1)
                                <div class="player_screen">
                                    {!! $anchor->live_stream !!}
                                </div>
                            @else
                                <div class="player_screen_over">
                                    <h2 class="player_screen_over_title">主播暂时不在家，看看其他<a href="{{ url('/anchors') }}">直播</a>吧！</h2>
                                    <div class="player_screen_over_list">
                                        <ul>
                                            @foreach($rec_anchors->take(-6) as $rec)
                                                <li>
                                                    <a href="{{ route('anchor.show', [$rec->id]) }}">
                                                        <div class="medi_video_hover player_screen_hover">
                                                            <span><img src="{{ $rec->cover }}"></span>
                                                            <div class="player_screen_pt">{{ $rec->live->name }}</div>
                                                            <div class="medi_video_play ">
                                                                <img src="{{ asset('home_new/images/zb/play_medi.png') }}">
                                                            </div>
                                                        </div>
                                                        <div class="medi_video_us player_screen_us">
                                                            <h2>{{ $rec->room_name }}</h2>
                                                            <p>
                                                                <span>{{ $rec->name }}</span>
                                                                <span><em></em>{{ num2word($rec->online) }}</span>
                                                            </p>
                                                        </div>
                                                    </a>
                                                </li>
                                            @endforeach
                                        </ul>
                                    </div>
                                </div>
                            @endif
                            <div class="ub_notice">
                                <div class="ub_notice_title"><img src="{{ asset('home_new/images/ub_detail/notice.png') }}" alt=""><span>公告</span></div>
                                <p>奇异果全体工作人员祝各位圣诞快乐</p>
                            </div>

                        </div>
                        <div class="ub_weibo_content" id="mainBox">
                            <div class="ub_weibo_wp" id="content">
                                <img class="ub_weibo_tx" src="{{ $anchor->avatar }}" alt="" />
                                <a class="ub_wb_name" href="">{{ $anchor->name }}</a><button class="wb_gz"></button>
                                {{--<div class="ub_weibo_block">--}}
                                {{--<span>12月16日  10：00 来自iphone 5s</span>--}}
                                {{--<p>今天马上要直播了，大家快来围观吧！！</p>--}}
                                {{--<div class="wb_img">--}}
                                {{--<div class="wb_img_block">--}}
                                {{--<img src="images/10ee435cb29a9b1577ab54b58a.jpg" alt="">--}}
                                {{--</div>--}}
                                {{--<div class="wb_img_block">--}}
                                {{--<img src="images/10ee435cb29a9b1577ab54b58a.jpg" alt="">--}}
                                {{--</div>--}}
                                {{--<div class="wb_img_block">--}}
                                {{--<img src="images/10ee435cb29a9b1577ab54b58a.jpg" alt="">--}}
                                {{--</div>--}}
                                {{--</div>--}}
                                {{--</div>--}}
                            </div>

                        </div>
                    </div>
                </div>

            </div>
        </div>
    </div>

    <div class="common_ub">
        <div class="box_title_ub">
            <div class="common_ub_title">
                <img src="{{ asset('home_new/images/ub_detail/c_title.png') }}" alt="">
                <h2>同类直播</h2>
            </div>
            <div class="ub_border common_ub_border">
                <div class="ub_border_l"></div>
                <div class="ub_border_r"></div>
            </div>
        </div>
        <div class="ub_video_box">
            <div class="medi_video_zb">
                <ul>
                    @foreach($rec_anchors->take(10) as $rec)
                        <li>
                            <a href="{{ route('anchor.show', [$rec->id]) }}">
                                <div class="medi_video_hover">
                                    <span><img src="{{ $rec->cover }}"></span>
                                    <div class="player_screen_pt">{{ $rec->live->name }}</div>
                                    <div class="medi_video_play">
                                        <img src="{{ asset('home_new/images/zb/play_medi.png') }}">
                                    </div>
                                </div>
                                <div class="medi_video_us">
                                    <h2>{{ $rec->room_name }}</h2>
                                    <p>
                                        <span>{{ $rec->name }}</span>
                                        <span><em></em>{{ num2word($rec->online) }}</span>
                                    </p>
                                </div>
                            </a>
                        </li>
                    @endforeach
                </ul>
            </div>
        </div>
    </div>
    <div class="common_ub">
        <div class="box_title_ub ub_float_l">
            <div class="common_ub_title">
                <img src="{{ asset('home_new/images/ub_detail/c_title.png') }}" alt="">
                <h2>推荐主播</h2>
            </div>
            <div class="ub_border common_ub_border common_ub_border_left">
                <div class="ub_border_l"></div>
                <div class="ub_border_r common_ub_border_l"></div>
            </div>
            <div class="ub_video_box ub_video_some_box">
                <div class="medi_video_zb some_zb">
                    <ul>
                        @foreach($top->take(4) as $rec)
                            <li>
                                <a href="{{ route('anchor.show', [$rec->id]) }}">
                                    <div class="medi_video_hover">
                                        <span><img src="{{ $rec->cover }}"></span>
                                        <div class="player_screen_pt">{{ $rec->live->name }}</div>
                                        <div class="medi_video_play">
                                            <img src="{{ asset('home_new/images/zb/play_medi.png') }}">
                                        </div>
                                    </div>
                                    <div class="medi_video_us">
                                        <h2>{{ $rec->room_name }}</h2>
                                        <p>
                                            <span>{{ $rec->name }}</span>
                                            <span><em></em>{{ num2word($rec->online) }}</span>
                                        </p>
                                    </div>
                                </a>
                            </li>
                        @endforeach
                    </ul>
                </div>
            </div>
        </div>
        <div class="box_title_ub ub_float_r">
            <div class="common_ub_title common_xg">
                <img src="{{ asset('home_new/images/ub_detail/g_title.png') }}" alt="">
                <h2>相关推荐</h2>
            </div>
            <div class="ub_border common_ub_border common_ub_border_right">
                <div class="ub_border_r common_ub_border_r"></div>
            </div>
            <div class="common_bq_box">
                <dl>
                    @foreach($anchor->tag()->getSimilars() as $tag)
                    <dt>
                        <a href="{{ $tag->url }}">{{ $tag->name }}</a>
                    </dt>
                    @endforeach
                </dl>
            </div>
        </div>
    </div>
    <script type="text/javascript">
        var doc = document;
        var _wheelData = -1;
        var mainBox = doc.getElementById('mainBox');

        function bind(obj, type, handler) {
            var node = typeof obj == "string" ? $(obj) : obj;
            if(node.addEventListener) {
                node.addEventListener(type, handler, false);
            } else if(node.attachEvent) {
                node.attachEvent('on' + type, handler);
            } else {
                node['on' + type] = handler;
            }
        }

        function mouseWheel(obj, handler) {
            var node = typeof obj == "string" ? $(obj) : obj;
            bind(node, 'mousewheel', function(event) {
                var data = -getWheelData(event);
                handler(data);
                if(document.all) {
                    window.event.returnValue = false;
                } else {
                    event.preventDefault();
                }
            });
            //火狐
            bind(node, 'DOMMouseScroll', function(event) {
                var data = getWheelData(event);
                handler(data);
                event.preventDefault();
            });

            function getWheelData(event) {
                var e = event || window.event;
                return e.wheelDelta ? e.wheelDelta : e.detail * 40;
            }
        }

        function addScroll() {
            this.init.apply(this, arguments);
        }
        addScroll.prototype = {
            init: function(mainBox, contentBox, className) {
                var mainBox = doc.getElementById(mainBox);
                var contentBox = doc.getElementById(contentBox);
                var scrollDiv = this._createScroll(mainBox, className);
                this._resizeScorll(scrollDiv, mainBox, contentBox);
                this._tragScroll(scrollDiv, mainBox, contentBox);
                this._wheelChange(scrollDiv, mainBox, contentBox);
                this._clickScroll(scrollDiv, mainBox, contentBox);
            },
            //创建滚动条
            _createScroll: function(mainBox, className) {
                var _scrollBox = doc.createElement('div')
                var _scroll = doc.createElement('div');
                var span = doc.createElement('span');
                _scrollBox.appendChild(_scroll);
                _scroll.appendChild(span);
                _scroll.className = className;
                mainBox.appendChild(_scrollBox);
                return _scroll;
            },
            //调整滚动条
            _resizeScorll: function(element, mainBox, contentBox) {
                var p = element.parentNode;
                var conHeight = contentBox.offsetHeight;
                var _width = mainBox.clientWidth;
                var _height = mainBox.clientHeight;
                var _scrollWidth = element.offsetWidth;
                var _left = _width - _scrollWidth;
                p.style.width = _scrollWidth + "px";
                p.style.height = _height + "px";
                p.style.left = _left + "px";
                p.style.position = "absolute";
                p.style.background = "#484848";
                p.style.top = "0px";
                contentBox.style.width = (mainBox.offsetWidth - _scrollWidth) + "px";
                var _scrollHeight = parseInt(_height * (_height / conHeight));
                if(_scrollHeight >= mainBox.clientHeight) {
                    element.parentNode.style.display = "none";
                }
                element.style.height = _scrollHeight + "px";
            },
            //拖动滚动条
            _tragScroll: function(element, mainBox, contentBox) {
                var mainHeight = mainBox.clientHeight;
                element.onmousedown = function(event) {
                    var _this = this;
                    var _scrollTop = element.offsetTop;
                    var e = event || window.event;
                    var top = e.clientY;
                    //this.onmousemove=scrollGo;
                    document.onmousemove = scrollGo;
                    document.onmouseup = function(event) {
                        this.onmousemove = null;
                    }

                    function scrollGo(event) {
                        var e = event || window.event;
                        var _top = e.clientY;
                        var _t = _top - top + _scrollTop;
                        if(_t > (mainHeight - element.offsetHeight)) {
                            _t = mainHeight - element.offsetHeight;
                        }
                        if(_t <= 0) {
                            _t = 0;
                        }
                        element.style.top = _t + "px";
                        contentBox.style.top = -_t * (contentBox.offsetHeight / mainBox.offsetHeight) + "px";
                        _wheelData = _t;
                    }
                }
                element.onmouseover = function() {
                    this.style.background = "#444";
                }
                element.onmouseout = function() {
                    this.style.background = "#666";
                }
            },
            //鼠标滚轮滚动，滚动条滚动
            _wheelChange: function(element, mainBox, contentBox) {
                var node = typeof mainBox == "string" ? $(mainBox) : mainBox;
                var flag = 0,
                    rate = 0,
                    wheelFlag = 0;
                if(node) {
                    mouseWheel(node, function(data) {
                        wheelFlag += data;
                        if(_wheelData >= 0) {
                            flag = _wheelData;
                            element.style.top = flag + "px";
                            wheelFlag = _wheelData * 12;
                            _wheelData = -1;
                        } else {
                            flag = wheelFlag / 12;
                        }
                        if(flag <= 0) {
                            flag = 0;
                            wheelFlag = 0;
                        }
                        if(flag >= (mainBox.offsetHeight - element.offsetHeight)) {
                            flag = (mainBox.clientHeight - element.offsetHeight);
                            wheelFlag = (mainBox.clientHeight - element.offsetHeight) * 12;
                        }
                        element.style.top = flag + "px";
                        contentBox.style.top = -flag * (contentBox.offsetHeight / mainBox.offsetHeight) + "px";
                    });
                }
            },
            _clickScroll: function(element, mainBox, contentBox) {
                var p = element.parentNode;
                p.onclick = function(event) {
                    var e = event || window.event;
                    var t = e.target || e.srcElement;
                    var sTop = document.documentElement.scrollTop > 0 ? document.documentElement.scrollTop : document.body.scrollTop;
                    var top = mainBox.offsetTop;
                    var _top = e.clientY + sTop - top - element.offsetHeight / 2;
                    if(_top <= 0) {
                        _top = 0;
                    }
                    if(_top >= (mainBox.clientHeight - element.offsetHeight)) {
                        _top = mainBox.clientHeight - element.offsetHeight;
                    }
                    if(t != element) {
                        element.style.top = _top + "px";
                        contentBox.style.top = -_top * (contentBox.offsetHeight / mainBox.offsetHeight) + "px";
                        _wheelData = _top;
                    }
                }
            }
        }
        new addScroll('mainBox', 'content', 'scrollDiv');


        var $follow_url = '{{ route('anchor.follow', [$anchor->id]) }}';
        var $is_bind_url = '{{ route('wx.is-bind') }}';
        var $is_subscribe_url = '{{ route('wx.is-subscribe') }}';

        var box = $('.viseo_ubfx span');

        var follow_btn = $('.ub_gzbtn');

        var unfollow = function () {
            //询问框
            layer.confirm('取消关注将不会返还积分！', {
                btn: ['确认','取消'],
                title : '确认取消关注',
                icon: 3
            }, function(){
                var room_url = "{{$anchor->url}}";
                var load_index = layer.load(1, {time: 10*1000});
                $.getJSON($follow_url, function (res) {
                    if (res.error == 1) box.html('<a  class="ub_csm" href="'+room_url+'" target="_blank" rel="nofollow">传送门</a><button class="ub_gzbtn" id="follow" onclick="follow()">关注</button>');
                    layer.close(load_index);
                    layer.alert(res.msg, {
                        icon: res.error
                    })
                });

            });
        };
        var　follow = function () {

            if (follow_btn.hasClass('login_in')) return;

            var load_index = layer.load(1, {time: 10*1000});

            $.getJSON($is_bind_url, function (res) {
                layer.close(load_index);

                if (res == "0") {
                    window.bind_wx = layer.confirm('绑定微信并关注奇异果公众号后你喜欢的主播上线时将会第一时间通知你哦~', {
                        btn: ['去绑定微信', '取消'],
                        title : '绑定微信',
                        icon: 3
                    }, function(){
                        layer.close(bind_wx);
                        window.bind_wx = layer.open({
                            type: 2,
                            border: [0],
                            title: false,
                            shadeClose: true,
                            closeBtn: true,
                            area: ['830px' , '400px'],
                            content: '{{url('auth/wxBind/').'/'.$anchor->id}}'
                        });
                    });
                } else {
                    load_index = layer.load(1, {time: 10*1000});
                    $.getJSON($is_subscribe_url, function (res) {
                        layer.close(load_index);

                        if (res == "0") {
                            layer.alert('<p style="text-align: center;"><img src="{{ asset('img/weixin_qrcode.jpg') }}" width="150" /> <p>关注微信公众号，即可收到主播上线通知！</p></p>');
                        } else {
                            layer.confirm('关注将扣除100积分', {
                                btn: ['确认','取消'],
                                title : '确认关注',
                                icon: 1
                            }, function(){
                                var room_url = "{{$anchor->url}}";
                                load_index = layer.load(1, {time: 10*1000});
                                $.getJSON($follow_url, function (res) {
                                    if (res.error == 1) box.html('<a  class="ub_csm" href="'+room_url+'" target="_blank" rel="nofollow">传送门</a><button class="ub_gzybtn" id="unfollow" onclick="unfollow()">已关注</button>');
                                    layer.close(load_index);
                                    layer.alert(res.msg, {
                                        icon: res.error
                                    })
                                });

                            });
                        }
                    });
                }

            });
        };
    </script>
@endsection